package com.ljh.account.mapper;

import com.ljh.account.dao.BankPartner;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BankPartnerMapper {

    // 插入新银行记录
    @Insert("INSERT INTO bank_partners (bank_name, location, cover_image, is_bindable) " +
            "VALUES (#{bankName}, #{location}, #{coverImage}, #{isBindable})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertBankPartner(BankPartner bankPartner);

    // 根据 ID 查询银行记录
    @Select("SELECT * FROM bank_partners WHERE id = #{id}")
    BankPartner selectBankPartnerById(int id);

    // 查询所有银行记录
    @Select("SELECT * FROM bank_partners")
    List<BankPartner> selectAllBankPartners();

    // 更新银行记录
    @Update("UPDATE bank_partners SET bank_name = #{bankName}, location = #{location}, " +
            "cover_image = #{coverImage}, is_bindable = #{isBindable}, updated_at = CURRENT_TIMESTAMP " +
            "WHERE id = #{id}")
    void updateBankPartner(BankPartner bankPartner);

    // 根据 ID 删除银行记录
    @Delete("DELETE FROM bank_partners WHERE id = #{id}")
    void deleteBankPartner(int id);

    // 分页查询
    @Select("SELECT * FROM bank_partners")
    List<BankPartner> selectBankPartners();



}